package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jarray;
import com.njuse.jvmfinal.runtimestructure.Jframe;

public class CASTORE extends Instruction {
	
	public  void readindex(ByteBuffer reader) {
		//pass
	}
	
	public  void execute(Jframe frame) {
		int top=frame.getStacktop();
		Object[] stack=frame.getManagestack();
		Object value=stack[top-1];
		int index=(int) stack[top-2];
		Jarray array=(Jarray) stack[top-3];
		top=top-3;
        Object[] arrayy=array.getJarray();
        arrayy[index]=value;
		array.setJarray(arrayy);
		frame.setStacktop(top);
	}
}
